<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>findx0BD</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : April 1999</div>
    <p>
      <b>findx0BD</b> -  Estimates state and B and D matrices of a discrete-time linear system</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>[X0,B,D] = findx0BD(A,C,Y,U,WITHX0,WITHD,TOL,PRINTW)   </tt>
      </dd>
      <dd>
        <tt>[x0,B,D,V,rcnd] = findx0BD(A,C,Y,U)  </tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>A</b>
        </tt>: state matrix of the system</li>
      <li>
        <tt>
          <b>C</b>
        </tt>: C matrix of the system</li>
      <li>
        <tt>
          <b>Y</b>
        </tt>: system output</li>
      <li>
        <tt>
          <b>U</b>
        </tt>: system input</li>
      <li>
        <tt>
          <b>WITHX0</b>
        </tt>: a switch for estimating the initial state x0.<ul>
          <li>
            <tt>
              <b>=  </b>
            </tt>1: estimate x0;</li>
          <li>
            <tt>
              <b>=  </b>
            </tt>0: do not estimate x0.</li>
        </ul>
        <p>
    Default:    WITHX0 = 1.
  </p>
      </li>
      <li>
        <tt>
          <b>WITHD</b>
        </tt>: a switch for estimating the matrix D.<ul>
          <li>
            <tt>
              <b>=  </b>
            </tt>1: estimate the matrix D;</li>
          <li>
            <tt>
              <b>=  </b>
            </tt>0: do not estimate the matrix D.</li>
        </ul>
        <p>
    Default:    WITHD = 1.
  </p>
      </li>
      <li>
        <tt>
          <b>TOL</b>
        </tt>: the tolerance used for estimating the rank of matrices.  If  TOL &gt; 0,  then the given value of  TOL  is used as a lower bound for the reciprocal condition number. Default:    prod(size(matrix))*epsilon_machine where epsilon_machine             is the relative machine precision.</li>
      <li>
        <tt>
          <b>PRINTW</b>
        </tt>: a switch for printing the warning messages.<ul>
          <li>
            <tt>
              <b>=  </b>
            </tt>1: print warning messages;</li>
          <li>
            <tt>
              <b>=  </b>
            </tt>0: do not print warning messages.</li>
        </ul>
        <p>
    Default:    PRINTW = 0.
  </p>
      </li>
      <li>
        <tt>
          <b>X0</b>
        </tt>: intial state of the estimated linear system.</li>
      <li>
        <tt>
          <b>B</b>
        </tt>: B matrix of the estimated linear system.</li>
      <li>
        <tt>
          <b>D</b>
        </tt>: D matrix of the estimated linear system.</li>
      <li>
        <tt>
          <b>V</b>
        </tt>: orthogonal matrix which reduces the system state matrix A to a real Schur form</li>
      <li>
        <tt>
          <b>rcnd</b>
        </tt>: estimates of the reciprocal condition numbers of the matrices involved in rank decisions.</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
    findx0BD  Estimates the initial state and/or the matrices B and D of a
    discrete-time linear system, given the (estimated) system
    matrices A, C, and a set of input/output data.</p>
    <p>
    [X0,B,D] = findx0BD(A,C,Y,U,WITHX0,WITHD,TOL,PRINTW)  estimates the
    initial state X0 and the matrices B and D of a discrete-time 
    system using the system matrices A, C, output data Y and the input 
    data U. The model structure is :</p>
    <pre>

     x(k+1) = Ax(k) + Bu(k),   k &gt;= 1,
     y(k)   = Cx(k) + Du(k),
   
    </pre>
    <p>
    The vectors y(k) and u(k) are transposes of the k-th rows of Y and U,
    respectively.</p>
    <p>
    [x0,B,D,V,rcnd] = findx0BD(A,C,Y,U)  also returns the orthogonal
    matrix V which reduces the system state matrix A to a real Schur
    form, as well as some estimates of the reciprocal condition numbers
    of the matrices involved in rank decisions.</p>
    <pre>

    B = findx0BD(A,C,Y,U,0,0)  returns B only, and
[B,D] = findx0BD(A,C,Y,U,0)    returns B and D only. 
   
    </pre>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>

//generate data from a given linear system
A = [ 0.5, 0.1,-0.1, 0.2;
      0.1, 0,  -0.1,-0.1;      
     -0.4,-0.6,-0.7,-0.1;  
      0.8, 0,  -0.6,-0.6];      
B = [0.8;0.1;1;-1];
C = [1 2 -1 0];
SYS=syslin(0.1,A,B,C);
nsmp=100;
U=prbs_a(nsmp,nsmp/5);
Y=(flts(U,SYS)+0.3*rand(1,nsmp,'normal'));

// Compute R
S=15;L=1;
[R,N,SVAL] = findR(S,Y',U');

N=3;
METH=3;TOL=-1;
[A,C] = findAC(S,N,L,R,METH,TOL);

[X0,B,D,V,rcnd] = findx0BD(A,C,Y',U');
SYS1=syslin(1,A,B,C,D,X0);


Y1=flts(U,SYS1);
xbasc();plot2d((1:nsmp)',[Y',Y1'])
 
  </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="findBD.htm">
        <tt>
          <b>findBD</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="inistate.htm">
        <tt>
          <b>inistate</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
  </body>
</html>
